﻿#include "widget.h"
#include "ui_widget.h"
#include <QtGlobal>

Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);

    m_pTimer = new QTimer(this);
    connect(m_pTimer, &QTimer::timeout, this, &Widget::setValue);
    this->setWindowTitle("LotteryDraw");

    ui->lcdNumber->setSegmentStyle(QLCDNumber::Flat);
    //调色板
    QPalette lcdpat = ui->lcdNumber->palette();
    /*设置颜色，整体背景颜色 颜色蓝色,此函数的第一个参数可以设置多种。如文本、按钮按钮文字、多种*/
    lcdpat.setColor(QPalette::Normal,QPalette::WindowText,Qt::red);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::on_startBtn_clicked()
{
    if(!m_pTimer->isActive())
    {
        m_pTimer->start(100);
    }
}

void Widget::on_stopBtn_clicked()
{
    if(m_pTimer->isActive())
    {
        m_pTimer->stop();
    }
}

void Widget::setValue()
{
    int iValue = qrand()%16 + 1;
    ui->lcdNumber->display(iValue);
}
